<?php
    include './connect.php';
    
    $strSQL = "SELECT * FROM `Equipment` WHERE ITDAssetNo = '".$_POST["txtCodeNo"]."' or Chassis = '".$_POST["txtChassis"]."'";
    
    $objQuery = mysqli_query($MechanicDB,$strSQL) or die(mysqli_error($MechanicDB)) ;
    if($objQuery->num_rows > 0){
        echo 'duplicate';
        return false;
    }
    
    $strSQL = "INSERT INTO `equipment`(`Chassis`, `ITDAssetNo`, `Description`, `EngineNo`, `EngineModel`
        , `Model`, `Brand`, `HP`, `WorkOrder`, `Location`
        , `SupplierCode`, `Mileage`, `Reading`, `Remark`, `Job`)  ";
    $strSQL .= " VALUES ('".$_POST["txtChassis"]."','".$_POST["txtCodeNo"]."','".$_POST["txtDescription"]."','".$_POST["txtEngineNo"]."','".$_POST["txtEngineModel"]."'
        ,'".$_POST["txtModel"]."','".$_POST["drpBrand"]."','".$_POST["txtHP"]."','".$_POST["txtWorkOrder"]."','".$_POST["drpLocation"]."'
        ,'".$_POST["drpSupplier"]."','".$_POST["txtMileage"]."','".$_POST["rdoReading"]."','".$_POST["txtRemark"]."','".$_POST["drpJob"]."')";
    //echo $strSQL;
    mysqli_query($MechanicDB,$strSQL) or die(mysqli_error($MechanicDB)) ;
    
    echo 'success';
?>
